package com.hr.剑指offer.work1;

import java.math.BigInteger;

/**
 * @author 周恒哲
 * @date 2020/06/16
 **/
public class 面试题14_II_剪绳子II {
    public int cuttingRope(int n) {
        if (n <= 3) {
            return n - 1;
        }
        int mod = (int) 1e9 + 7;
        long res = 1;
        while (n > 4) {
            res *= 3;
            res %= mod;
            n -= 3;
        }
        return (int) (res * n % mod);
    }
}
